package com.gxa.controller.fwgl.yhgl;


import com.gxa.annotation.Perm;
import com.gxa.pojo.dto.fwgl.OldInfoDto;
import com.gxa.pojo.dto.fygl.sfxmwh.CharTypeDto;
import com.gxa.pojo.entity.fwgl.TOldinfo;
import com.gxa.pojo.entity.fygl.sfxmwh.CharType;
import com.gxa.service.fwgl.yhgl.OldInfoService;
import com.gxa.service.fygl.sfxmwh.QueryAllService;
import com.gxa.utils.QueryResult;
import com.gxa.utils.Result;
import com.gxa.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author：lizhijun
 * @Package：{PROJECT_NAME}
 * @name：{DATE} {NAME}
 */
@RestController
@RequestMapping("/oldinfo")
public class OldInfoController {

    @Autowired
    private OldInfoService oldInfoService;

    @GetMapping("/queryAll")
    public Result queryAll(OldInfoDto oldInfoDto){
        System.out.println(oldInfoDto);
        QueryResult queryResult = oldInfoService.queryAll(oldInfoDto);
        return ResultUtils.buildSuccess(queryResult.getData(),queryResult.getCount());
    }

    @RequestMapping("/add")
    public Result addOldinfo( TOldinfo oldinfo){
        System.out.println(oldinfo);
        oldInfoService.add(oldinfo);
        return ResultUtils.buildSuccess();
    }

    @RequestMapping("/update")
    public Result updateOldinfo(TOldinfo oldinfo){
        oldInfoService.update(oldinfo);
        return ResultUtils.buildSuccess();
    }

    @GetMapping("/delete")
    public Result deleteOldinfoById(@RequestParam List<Integer> id){
        System.out.println("删除传过来的id：----------"+ id);
        oldInfoService.delete(id);
        return ResultUtils.buildSuccess();
    }

    @GetMapping("/queryById")
    public Result queryById(int id ){

        QueryResult queryResult = oldInfoService.queryById(id);
        return ResultUtils.buildSuccess(queryResult.getData(),queryResult.getCount());
    }
    @RequestMapping("/find")
    public Result findTypeByName(String patientName){
        oldInfoService.findByName(patientName);
        return ResultUtils.buildSuccess();
    }


}
